Skip to content

Conversation

@StyleShit
Copy link
Contributor

Closes #368

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new ESLint rule no-matching-violation-suggest-message-ids that enforces suggestions to have different messageIds than their parent report violations. This helps ensure that suggestion messages are actionable and distinct from the main violation message.

Key Changes:

  • Introduced the new rule implementation with support for static and dynamic messageId detection
  • Added comprehensive test coverage for various scenarios including conditional expressions and external variables
  • Extended utility functions to support string literal type checking

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/rules/no-matching-violation-suggest-message-ids.ts Implements the core rule logic for detecting matching messageIds between violations and suggestions
tests/lib/rules/no-matching-violation-suggest-message-ids.ts Provides comprehensive test cases covering valid and invalid scenarios
lib/utils.ts Adds isStringLiteral utility function for type checking
lib/types.ts Defines StringLiteral type for type-safe string literal handling
lib/index.ts Registers the new rule in the plugin's rule registry
docs/rules/no-matching-violation-suggest-message-ids.md Documents the rule with examples and usage guidance
README.md Updates the rules table to include the new rule

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, just a minor suggestion, thanks! 👍

Comment on lines 39 to 45
let contextIdentifiers: Set<Node>;

return {
Program(ast) {
contextIdentifiers = getContextIdentifiers(scopeManager, ast);
},

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just get the ast directly.

Suggested change
let contextIdentifiers: Set<Node>;
return {
Program(ast) {
contextIdentifiers = getContextIdentifiers(scopeManager, ast);
},
const contextIdentifiers: Set<Node> = getContextIdentifiers(scopeManager, sourceCode.ast);
return {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@aladdin-add
Copy link
Contributor

and the rule is a candidate to be enabled in recommended config. refs: #538

@StyleShit
Copy link
Contributor Author

and the rule is a candidate to be enabled in recommended config. refs: #538

Should i open a draft PR for this after merging?

@aladdin-add
Copy link
Contributor

and the rule is a candidate to be enabled in recommended config. refs: #538

Should i open a draft PR for this after merging?

please feel free, we'll just merge it when we're ready for a major release.

@StyleShit
Copy link
Contributor Author

StyleShit commented Nov 10, 2025

please feel free, we'll just merge it when we're ready for a major release.

you mean add it as recommended here and you'll merge this PR to the major release? or you'll merge this and then i'll open a pr for recommended?

@aladdin-add aladdin-add merged commit 57cbe73 into eslint-community:main Nov 10, 2025
22 of 23 checks passed
@aladdin-add
Copy link
Contributor

sorry for not clear - i mean another pr to add it to recommended config. 🙏

@StyleShit
Copy link
Contributor Author

@aladdin-add

Opened #570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rule: require suggestions have different messageId than their parent report

2 participants